using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using ThoiTrang.Entities;

public partial class UserControls_ArticleItem : System.Web.UI.UserControl
{  
    public string DetailLink
    {        
        set
        {
            imgLnkDetail.HRef = value;
            txtLnkDetail.HRef = value;
        }
    }

    public string ImgSrc
    {
        set
        {
            img.Src = value;
        }
    }

    public string Title
    {
        set
        {
            txtLnkDetail.InnerHtml = value;
        }
    }
	
    protected void Page_Load(object sender, EventArgs e)
    {

    }

    public void SetValue(a_Article art, int length)
    {
        //HtmlAnchor imgLnkDetail = e.Item.FindControl("imgLnkDetail") as HtmlAnchor;
        //HtmlAnchor txtLnkDetail = e.Item.FindControl("txtLnkDetail") as HtmlAnchor;
        //HtmlImage img = e.Item.FindControl("img") as HtmlImage;
        string link = ResolveUrl(String.Format("~/detail.aspx?{0}={1}&{2}={3}",FOConstants.QSP_AID, art.ID, FOConstants.QSP_CKID, SessionManager.GetCookie()));
        //string content = (length <= art.UTitle.Length) ? "" : art.UBody.Substring(0, length - art.UTitle.Length);
        string content = string.Concat(" ", HTMLHelper.StripHtml(art.UBody, false));
        imgLnkDetail.HRef = link;
        imgLnkDetail.Title = art.KTitle;
        txtLnkDetail.HRef = link;
        txtLnkDetail.Title = art.KTitle;
        txtLnkDetail.InnerHtml = art.UTitle;
        img.Src = TTHelper.GetImagePath(art);
        img.Alt = art.KTitle;
        int titleLen = TTHelper.WordCounter(art.UTitle);
        txtContent.InnerHtml = (length <= titleLen) ? "" : TTHelper.GetSubString(content, length - titleLen); 
    }
}
